package struts.action;

import java.util.Map;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import struts.form.XmlBean;
import struts.util.StrutsConfigReader;

public class ActionListener implements ServletContextListener {

    @Override
    public void contextDestroyed(ServletContextEvent arg0) {
        System.out.println("信息：系统已经注销！");

    }

    @Override
    public void contextInitialized(ServletContextEvent arg0) {
        ServletContext context = arg0.getServletContext();
        String xmlpath = context.getInitParameter("struts-config");
        String servletpath = context.getRealPath("\\");
        
        try {
            Map<String,XmlBean> map = StrutsConfigReader.getStrutsActionBeanMap(servletpath + xmlpath);
            context.setAttribute("struts", map);
        } catch (Exception e) {
            e.printStackTrace();
        }
        System.out.println("信息：系统已经加载完成！");
    }

}
